using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Web.UI;

namespace Axe.Web.Controls
{
    public class ImageSwitch : Image
    {
        #region public override string ImageUrl
        [Browsable(false)]
        public override string ImageUrl
        {
            get
            {
                if (Condition)
                    return TrueImageUrl;
                else
                    return FalseImageUrl;
            }
        } 
        #endregion

        #region public bool Condition
        [DefaultValue(false)]
        [Category("Apperance")]
        [Bindable(true, BindingDirection.TwoWay)]
        public bool Condition
        {
            get
            {
                object o = ViewState["Condition"];
                if (o == null)
                    return false;

                return (bool)o;
            }
            set
            {
                ViewState["Condition"] = value;
            }
        } 
        #endregion

        [UrlProperty]
        [DefaultValue("")]
        [Category("Apperance")]
        [Bindable(true, BindingDirection.TwoWay)]
        public string TrueImageUrl
        {
            get
            {
                object o = ViewState["TrueImageUrl"];
                if (o == null)
                    return "";

                return o as string;
            }
            set
            {
                ViewState["TrueImageUrl"] = value;
            }
        }

        [UrlProperty]
        [DefaultValue("")]
        [Category("Apperance")]
        [Bindable(true,BindingDirection.TwoWay)]
        public string FalseImageUrl
        {
            get
            {
                object o = ViewState["FalseImageUrl"];
                if (o == null)
                    return "";

                return o as string;
            }
            set
            {
                ViewState["FalseImageUrl"] = value;
            }
        }
    }
}
